Consider config.relative_url_root in ActsAsResourceController.base_url#1282
Merged
lgebhardt merged 3 commits intoJSONAPI-Resources:masterfrom Sep 16, 2019
tobias-bischoff:patch-2
Merged
Consider config.relative_url_root in ActsAsResourceController.base_url#1282lgebhardt merged 3 commits intoJSONAPI-Resources:masterfrom tobias-bischoff:patch-2
lgebhardt merged 3 commits intoJSONAPI-Resources:masterfrom
tobias-bischoff:patch-2
Conversation
config.relative_url_root in ActsAsResourceController.base_url
config.relative_url_root in ActsAsResourceController.base_url
Contributor
Author
|
Note: I ran the test suite locally (ruby 2.6.3, rails 5.2.3, command However, Travis CI jobs all failed because subsequent tests suddenly included |
Contributor
Author
|
@lgebhardt FYI: It seems Travis fails on specific Ruby/Rails combinations due to a bundler version error. This seems unrelated to my PR since it's also happening in other PRs. The builds where bundler actually runs are fine. |
When Rails is deployed to a subdirectory per [the official guide instructions](https://guides.rubyonrails.org/configuring.html#deploy-to-a-subdirectory-relative-url-root), JSON:API should take this into account. Implementation detail: Switched from string concatenation (`+`) to string interpolation because `Rails.application.config.relative_url_root` might be `nil`, which would cause an error as @hlogmans [already stated](https://github.com/cerebris/jsonapi-resources/issues/473#issuecomment-153719383). Tested with: - Setting `RAILS_RELATIVE_URL_ROOT=/subdirectory` - Adding `config.relative_url_root = '/subdirectory'` in application.rb or <environment>.rb Fixes #473
Signed-off-by: Tobias Grasse <tg@glancr.de>
Test suite runs fine without this locally (ruby 2.6.3, Rails 5.2.3), but Travis CI builds all fail because subsequent tests expect a clean base URL. Signed-off-by: Tobias Grasse <tg@glancr.de>
Contributor
|
@tobias-grasse Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Rails is deployed to a subdirectory per the official guide instructions, JSON:API should take this into account.
Implementation detail: Switched from string concatenation (
+) to string interpolation becauseRails.application.config.relative_url_rootmight benil, which would cause an error as @hlogmans already stated.Tested with:
RAILS_RELATIVE_URL_ROOT=/subdirectoryconfig.relative_url_root = '/subdirectory'in application.rb or .rbFixes #473
All Submissions:
Bug fixes and Changes to Core Features:
Test Plan:
Unit test:
bundle exec ruby -I test test/controllers/controller_test.rb -n test_links_include_relative_rootManual testing:
config.relative_url_root = '/subdirectory'toconfig/application.rbExpected result: Link objects contain
/subdirectoryReviewer Checklist: